{include file="common/header"}
<link href="/static/admin/css/other.css" rel="stylesheet">
<main class="lyear-layout-content">
    <div class="container-fluid">
        <div class="row ant-menu-submenu">
            <div class="col-lg-12 p10">
                <div class="card right-card">
                    <div class="right-card-header card-header mb0">
                        <h4>{:lang('attac.Attachment management')}</h4>
                    </div>
                    <div class="card-body">
                        <div class="table-responsive">
                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th width="3%">ID</th>
                                    <th width="10%">{:lang('attac.Name of the attachment')}</th>
                                    <th width="10%">{:lang('attac.Attachment path')}</th>
                                    <th width="10%">{:lang('attac.The heir')}</th>
                                    <th width="5%">ip</th>
                                    <th width="13%">{:lang('attac.Upload time')}</th>
                                    <th width="10%">{:lang('attac.Attachment MD5')}</th>
                                    <th width="5%">{:lang('public.operation')}</th>
                                </tr>
                                </thead>
                                <tbody>
                                {foreach $attachment as $item}
                                <tr>
                                    <td>{$item['id']}</td>
                                    <td>{$item['title']}</td>
                                    <td><input type="text" class="form-control" value="{if strpos($item['path'], 'http') === false}{:request()->domain()}{/if}{$item['path']}"></td>
                                    <td>{if $item['user_type']==1}{:lang('public.Customer service')}{else/}{:lang('public.tourists')}{/if} - {:getUserVlaue($item['user_id'],$item['user_type'], 'nick')}</td>
                                    <td>{$item['ip_info']}</td>
                                    <td>{:date('Y年m月d日 H:i',$item['add_time'])}</td>
                                    <td>{:__empty($item['md5'])}</td>
                                    <td>
                                        <div class="btn-group">
                                            <a class="btn btn-xs btn-success" href="#!" data-id="{$item['id']}" id="delattachment" data-toggle="tooltip" data-original-title="{:lang('public.delete')}">
                                                <i class="iconfont icon-shanchu"></i>
                                            </a>
                                        </div>
                                    </td>
                                </tr>
                                {/foreach}
                                </tbody>
                            </table>
                        </div>
                        {$attachment->render()|raw}
                    </div>
                </div>
            </div>
        </div>
    </div>
</main>
{include file="common/footer"}
<script type="text/javascript" src="/static/admin/js/set.js"></script>
<script type="text/javascript">
    let IM_config = {
        delattachment: "{:adminUrl('admin/Attachment/del')}"
    };

    $('.btn-group #delattachment').on('click', function() {
        $.post(IM_config.delattachment, {id:$(this).attr('data-id')}, function (res) {
            we_im_msg(res.msg);
            setTimeout(function() {
                window.location.reload();
            },1000);
        });
    });

</script>